package com.paul.sys.tools;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>Title: aria</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2008</p>
 * <p>Company: china317</p>
 * @author mjw
 * @version 1.0
 */

public class DateTime {
	/*
	 * yyyyMMddHHmmss
	 */
	
	public static final String PATTERN_0 = "yyyyMMddHHmmss";
	public static final String PATTERN_yyyyMMddHHmmss = PATTERN_0;
	public static final SimpleDateFormat FORMATTER_0 = new SimpleDateFormat(PATTERN_0);
	/*
	 * yyyy-MM-dd HH:mm:ss
	 */
	public static final String PATTERN_1 = "yyyy-MM-dd HH:mm:ss";
	public static final SimpleDateFormat FORMATTER_1 = new SimpleDateFormat(PATTERN_1);
	/*
	 * yyyy-MM-dd
	 */
	public static final String PATTERN_2 = "yyyy-MM-dd";
	/*
	 * yyyy年MM月dd日 HH时mm分ss秒
	 */
	public static final String PATTERN_3 = "yyyy年MM月dd日 HH时mm分ss秒";
	/*
	 * yyyy年MM月dd日
	 */
	public static final String PATTERN_4 = "yyyy年MM月dd日";
	/*
	 * yyyy-MM-dd HH:mm
	 */
	public static final String PATTERN_5 = "yyyy-MM-dd HH:mm";
	/*
	 * yyyy年MM月dd日 HH时mm分
	 */
	public static final String PATTERN_6 = "yyyy年MM月dd日 HH时mm分";
	/**
	 * yyyyMMdd
	 */
	public static final String PATTERN_7 = "yyyyMMdd";
	
	public static final SimpleDateFormat FORMATTER_7 = new SimpleDateFormat(PATTERN_7);
	
	public static final String PATTERN_8 = "yyyyMMddHHmm";
	public static final SimpleDateFormat FORMATTER_8 = new SimpleDateFormat(PATTERN_8);
	
	public static final String PATTERN_9 = "HHmm";
	
	public static final String PATTERN_10 = "yyyy-MM-dd";
	
	public static final SimpleDateFormat FORMATTER_9 = new SimpleDateFormat(PATTERN_9);
    public static String getSysTime(String pattern) {
        return new SimpleDateFormat(pattern).format(new Date());
    }//getSysTime//

   
   

    public static String formatDate(Date date,String pattern){
        SimpleDateFormat formatter = new SimpleDateFormat(pattern);
        return formatter.format(date);
    }
    
    public static String formatDateyyyy_MM_dd(Date date){
    	SimpleDateFormat formatter = new SimpleDateFormat(PATTERN_10);
        return formatter.format(date);
    }

    public static String formatTime(String time,String pattern_ori,String pattern_aim){
        try{
            if ( time == null )
                return "";
           return (formatDate(parseTime(time,pattern_ori),pattern_aim));
        }catch(Exception e){
            return "";
        }

    }//formatTime//

    public static Date parseTime(String time,String pattern){
        try{
            SimpleDateFormat formatter = new SimpleDateFormat( pattern );
            return formatter.parse( time );
        }catch(Exception e){
            return null;
        }
    }

   
    

    public static void main(String[] a)throws Exception{
        System.out.println(formatDateyyyy_MM_dd(new Date()));
    }

}//DateTime//

